Core: add initial sniffs for modifier keyword ordering rules #2102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Core: move rules related to property/method modifier order from
Extra
toCore
For property declarations, this is already covered by the
PSR2.Classes.PropertyDeclaration
sniff.For method declarations, the
PSR2.Methods.MethodDeclaration
sniff has now been moved fromExtra
toCore
.The
PSR2.Methods.MethodDeclaration
sniff contains one additional error code, which IMO should probably not (yet) go into theCore
ruleset.Underscore
- which warns against prefixing a method name with an underscore, advising to use visibility instead.While I'm 100% in favour of this, introducing this for WP Core would be problematic as renaming (
public
/protected
) methods would be a BC-break.As this rule was previously already included in the
Extra
ruleset, the error code which is being silenced forCore
, will be "unsilenced" again forExtra
.The
PSR2.Classes.PropertyDeclaration
sniff does not yet account for ordering the visibility vs readonly keywords.I have opened a PR upstream - squizlabs/PHP_CodeSniffer#3637 - proposing to add a check for this to the
PSR2.Classes.PropertyDeclaration
sniff.Refs:
Extra
#1103Core: move last modifier keyword sniff from Extra to Core
While this was not explicitly mentioned in the Make post, it is implied (via the code samples) that there should be exactly one space after each modifier keyword for properties and methods.
This was already being checked for in
Extra
. I'm proposing to move this sniff to theCore
ruleset.Note: I've checked and introducing this sniff to the
Core
ruleset does not yield any issues for WP Core as is, so it would be a silent introduction.Refs: